package com.example.em.service;

import com.example.em.mapper.AttendanceMapper;
import com.example.em.model.Attendance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AttendanceService {
    @Autowired
    private AttendanceMapper attendanceMapper;
    
    public List<Map<String, Object>> getAllAttendanceWithEmployeeInfo() {
        return attendanceMapper.findAllWithEmployeeInfo();
    }
    
    public Attendance getAttendance(Long id) {
        return attendanceMapper.findById(id);
    }
    
    public List<Map<String, Object>> getAttendanceByEmployee(Long employeeId) {
        return attendanceMapper.findByEmployeeId(employeeId);
    }
    
    public List<Map<String, Object>> getAttendanceByDate(String date) {
        return attendanceMapper.findByDate(date);
    }
    
    public void addAttendance(Attendance attendance) {
        attendanceMapper.insert(attendance);
    }
    
    public void updateAttendance(Attendance attendance) {
        attendanceMapper.update(attendance);
    }
    
    public void deleteAttendance(Long id) {
        attendanceMapper.delete(id);
    }
    
    public List<String> getAllDepartments() {
        return attendanceMapper.findAllDepartments();
    }
    
    public void deleteTodayAttendance() {
        attendanceMapper.deleteTodayAttendance();
    }
} 